/*轮播图 */
$(".swiper-container").carousel({
    width: 1520,
    height: 600,
    speed: 3e3,
    needPrevAndNextBtnGroup: true,
    needPagination: true
  });

  /*浮动广告 */
  /*----------浮动广告------------*/
  FloatAd("#floadAD");
  //浮动广告
  function FloatAd(selector) {
    var obj = $(selector);
    if (obj.find(".item").length == 0) return;
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();  //获得浏览器长宽
    var dirX = -1.5;//水平漂浮方向+距离，正右负左
    var dirY = -1;//垂直漂浮方向+距离，正下负上

    var delay = 30;//定期执行的时间间隔ms
    obj.css({ left: windowWidth / 2 - obj.width() / 2 + "px", top: windowHeight / 2 - obj.height() / 2 + "px" });//设置成在页面中间
    obj.show();//元素默认隐藏
    var handler = setInterval(move, delay);//返回值取消定期执行
    
    //鼠标经过时暂停
    obj.hover(function () {
      clearInterval(handler);
    }, function () {
      handler = setInterval(move, delay);
    });
    obj.find(".close").click(function () {
      close();
    });

    $(window).resize(function () {//重新获取浏览器大小
      windowHeight = $(window).height();
      windowWidth = $(window).width();
    });
    function move() {
      var currentPos = obj.position();//获取当前位置JQuery，
      var nextPosX = currentPos.left + dirX;
      var nextPosY = currentPos.top + dirY;

      if (nextPosX >= windowWidth - obj.width()) {//当漂浮到右边时关闭漂浮窗口，如不需要可删除
        close();
      }

      //触底反弹
      if (nextPosX <= 0 || nextPosX >= windowWidth - obj.width()) {
        dirX = dirX * -1;//改变方向
        nextPosX = currentPos.left + dirX;
      }
      if (nextPosY <= 0 || nextPosY >= windowHeight - obj.height() - 5) {           
        dirY = dirY * -1;//改变方向
        nextPosY = currentPos.top + dirY;
      }
      obj.css({ left: nextPosX + "px", top: nextPosY + "px" });//移动到下一个位置
    }

    function close() {
      clearInterval(handler);
      obj.remove();
    }
  }
/*图标切换*/
// let myImage=document.querySelector('img');

// myImage.onclick=function(){
//     let mySrc=myImage.getAttribute('src');
//     //获取这张图片的src属性值
//     if(mySrc==='/images/动画.svg'){
//         myImage.setAttribute('src','/images/现实.svg');
//     }
//     else{
//         myImage.setAttribute('src','/images/动画.svg');
//     }
// }

